package com.huang.design.creatation.prototype;

import java.util.HashMap;
import java.util.Map;


public class HuangMyBatis {

    private Map<String,Object> map=new HashMap<>();

    public Object getUser(String name){
        if(map.get(name)==null){
            return  getUserByName(name);
        }else {
           User user= (User) map.get(name);
        return  user.clone();

        }

    }

    private Object getUserByName(String name) {

            System.out.println("查询数据库");
            User user = new User();
            user.setAge(11);
            user.setName(name);
            map.put(name,user.clone());
            return user;



    }
}
